from datetime import datetime, timezone
from sqlalchemy import Column, ForeignKey, DateTime
from sqlalchemy.dialects.postgresql import UUID as PostgresUUID
from db.base import Base
import uuid

class RiskGuaranteeRelation(Base):
    """风险与保障关联表模型"""
    __tablename__ = "risk_guarantee_relation"

    id = Column(PostgresUUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    risk_item_id = Column(PostgresUUID(as_uuid=True), ForeignKey("compliance_item.id", ondelete="CASCADE"), nullable=False)
    guarantee_item_id = Column(PostgresUUID(as_uuid=True), ForeignKey("compliance_item.id", ondelete="CASCADE"), nullable=False)
    created_at = Column(DateTime(timezone=True), default=datetime.now(timezone.utc), nullable=False)

    class Config:
        from_attributes = True 